const mysql = require('mysql');

/**
 * @param {String}   sql   sql语句
 * @returns 
 */
function myQuery(sql) {
    // 创建连接并配置
    let conn = mysql.createConnection({
        host: '127.0.0.1',
        port: 3306,
        user: 'root',
        password: 'root',
        database: 'rc_h5'
    });
    // 启用连接
    conn.connect();
    return new Promise((resolve, reject) => {
        conn.query(sql,(err, result) => {
            resolve([err,result]);
            conn.end();
        });
    });
}

module.exports = myQuery;